﻿// 控制每个页面 <div id="toolbar">btns</div>中按钮显示
$(function() {
	var rights = '';
	var $btns = $('#toolbar div .easyui-linkbutton, #toolbar .easyui-linkbutton, #toolbar .easyui-menubutton, .rights_item .menu-item');
	var btnlen = $btns.length;
	$btns.hide();
	$btns.each(function(i) {
		if (i == btnlen - 1)
			rights += $(this).attr('id').split('_')[1];
		else
			rights += ($(this).attr('id').split('_')[1] + ',');
	});
	if (rights.length > 0) {
		var params = {};
		params.rights = rights;
		$.get(basePath + '/index/list_rights', params, function(data) {
			initpage(data.issuper);
			for (var i = 0; i < data.rights.length; i++) {
				$('#btn_' + data.rights[i]).show();
			}
		});
	}
});

function initpage(issuper) {
	// 设置表单，调用每个页面中的setForm()方法
	//if (!issuper && $.isFunction(window.setForm)) {
	if ($.isFunction(window.setForm)) {
		setForm();
	}
	if ($.isFunction(window.load)) {
		load();
	}
}